Midy's theorem